

// 封装的自定义服务
const install = (Vue, vm) => {

      let check = () => 
    {   
    
      let auth = uni.getStorageSync('auth')
     
   
  
  


        // 订单提醒
        uni.request({
          url: 'https://luxuries.h1668.com/first/order/order/ordertotal', //仅为示例，并非真实接口地址。
          data: {
            adminid:auth.id,
            stoid:auth.stoid
          },
          method:"POST",
          header: {
            'X-Requested-With': 'XMLHttpRequest'
          },
          success: (res) => {

            let total = 0
            let orderstatus = 0

            total = res.data.data.total
            orderstatus = res.data.data.status
         
            if(!auth || JSON.stringify(auth) == "{}")
            {
              let message = "未登录"
              return message
            }else
            {
              if( total != 0 || orderstatus !=0 )//如果auth为空不存在并且auth对象为空对象
              {
      
                uni.vibrateLong()
                const innerAudioContext = uni.createInnerAudioContext() // 创建InnerAudioContext实例
                innerAudioContext.src = 'https://luxuries.h1668.com/first/notice/ordernotice.mp3' // 指定音频文件路径
                innerAudioContext.play() // 播放音
      
              }else
              {
      
            
      
               
                let message = "暂无订单"
                return message
              } 
            }
     
         

          }

          
        });

        // 审批提醒
        uni.request({
          url: 'https://luxuries.h1668.com/first/depot/depot/depottotal', //仅为示例，并非真实接口地址。
          data: {
            adminid:auth.id,
            stoid:auth.stoid
          },
          method:"POST",
          header: {
            'X-Requested-With': 'XMLHttpRequest'
          },
          success: (res) => {

            let hiretotal = 0
            let hireorderstatus = 0

            hiretotal = res.data.data.total
            hireorderstatus = res.data.data.status
         
            if(!auth || JSON.stringify(auth) == "{}")
            {
              let message = "未登录"
              return message
            }else
            {
              if( hiretotal != 0 || hireorderstatus !=0 )//如果auth为空不存在并且auth对象为空对象
              {
      
                uni.vibrateLong()
                const innerAudioContext = uni.createInnerAudioContext() // 创建InnerAudioContext实例
                innerAudioContext.src = 'https://luxuries.h1668.com/notice/shenpinotice.mp3' // 指定音频文件路径
                innerAudioContext.play() // 播放音
      
              }else
              {
      
            
      
               
                let message = "暂无审批订单"
                return message
              } 
            }
     
         

          }

          
        });






    
    }
  
    // vm == 全局app 
    // $u == uviewui 
    // auth == 自定义的服务名称  是一个对象类型
      vm.$u.count = {
        check
      }
  }
  
  module.exports = {
    install
  }